<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>支付首页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="hotcss" content="design-width=640 max-width=640 initial-dpr=1">
    <link href="/vendor/layui-v2.8.8/layui/css/layui.css?v={{ time() }}" rel="stylesheet">
    <script src="/vendor/layui-v2.8.8/layui/layui.js?v={{ time() }}"></script>
    @vite(['resources/scss/switch_pay/index.scss', 'resources/js/switch_pay.js'])
</head>

<body>
    <div class="container" id="vapp">
    </div>
</body>
<script>
    document.addEventListener('DOMContentLoaded', function() {
        const app = vueCreateApp({
            data() {
                return {
                    tradeNo: '{{ $order->trade_no }}',
                    wexinPayPlatform: 22,
                }
            },
            mounted() {
                this.weixinPay()
            },
            methods: {
                weixinPay() {
                    var _this = this
                    var params = {
                        trade_no: _this.tradeNo,
                        pay_platform: _this.wexinPayPlatform
                    }
                    http.post('/switch_pay/click_pay', params, function(code, msg, data) {
                        if (code !== 0) {
                            layer.msg(msg)
                            return
                        }

                        var url = data.url;
                        window.location.href = url;
                    }, true);
                }
            }
        })
        app.mount('#vapp')
    })
</script>

</html>
